//package top.qitun.config;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.security.authentication.AuthenticationManager;
//import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
//import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
//import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
//import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
//
//@Configuration
//@EnableGlobalMethodSecurity(prePostEnabled = true)
//@EnableWebSecurity
//public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
//
//    @Autowired
//	public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
//		auth.inMemoryAuthentication().withUser("user").password("password").roles("USER").and().withUser("admin")
//				.password("password").roles("USER", "ADMIN");
//	}
//    
////    @Autowired
////	private JsonWebTokenAuthenticationProvider authenticationProvider;
//    
////    @Override
////	protected void configure(AuthenticationManagerBuilder auth) throws Exception {
////		auth.authenticationProvider(authenticationProvider);
////	}
//    
//    @Override
//    @Bean
//    public AuthenticationManager authenticationManagerBean() throws Exception {
//        return super.authenticationManagerBean();
//    }
//    
//    @Override
//    protected void configure(HttpSecurity http) throws Exception {
//        http
//                .authorizeRequests()
//                .antMatchers("/resources/**").permitAll()
//                .anyRequest().authenticated()
//                .and()
//                .formLogin()
//                .loginPage("/login")
//                .permitAll()
//                .and()
//                .logout()
//                .permitAll()
////              
//                .and()
//                .csrf().disable();
////      http.csrf().disable().exceptionHandling().authenticationEntryPoint(
//      //                (request, response, authException) -> response.sendError(HttpServletResponse.SC_UNAUTHORIZED)).and()
//      //                .authorizeRequests().antMatchers("/**").authenticated().and().httpBasic();
////      super.configure(http);
//    }
//
////    @Configuration
////    @EnableAuthorizationServer
////    protected static class OAuth2Config extends AuthorizationServerConfigurerAdapter {
////
////        @Override
////        public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
////            clients.inMemory()
////                    .withClient("acme")
////                    .secret("acmesecret")
////                    .scopes("openid")
////                    .authorizedGrantTypes("implicit","authorization_code", "refresh_token",
////                            "password");
////        }
////        
////        @Override
////        public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
////            endpoints.tokenStore(tokenStore()).tokenEnhancer(jwtTokenEnhancer())
////                    .authenticationManager(authenticationManager);
////        }
////        
////        
////        @Autowired
////        @Qualifier("authenticationManagerBean")
////        private AuthenticationManager authenticationManager;
////
////        @Bean
////        public TokenStore tokenStore() {
////            return new JwtTokenStore(jwtTokenEnhancer());
////        }
////
////        //    @Bean
////        //    protected JwtAccessTokenConverter jwtTokenEnhancer() {
////        //    KeyStoreKeyFactory keyStoreKeyFactory =
////        //            new KeyStoreKeyFactory(new ClassPathResource("jwt.jks"), "mySecretKey".toCharArray());
////        //        JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
////        //        converter.setKeyPair(keyStoreKeyFactory.getKeyPair("jwt"));
////        //        return converter;
////        //    }
////
////        @Bean
////        protected JwtAccessTokenConverter jwtTokenEnhancer() {
////            JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
////            converter.setSigningKey("123");
////            return converter;
////        }
////        
////    }
//    
//}
